import controlP5.*; import processing.serial.*; Serial port; ControlP5 cp5; PFont font; void setup(){ size(620,550); printArray(Serial.list()); port = new Serial(this, "COM3", 9600); int myColor = color(255,0,0); cp5 = new ControlP5(this); font = createFont("calibri bold", 25); cp5.addButton("red") .setPosition(100, 100) .setSize(120, 70) .setFont(font) ; cp5.addButton("green") .setPosition(250, 100) .setSize(120, 70) .setFont(font) ; cp5.addButton("blue") .setPosition(400,100) .setSize(120, 70) .setFont(font) ; cp5.addButton("alloff") .setPosition(175, 200) .setSize(120, 70) .setFont(font) ; cp5.addButton("allon") .setPosition(325, 200) .setSize(120, 70) .setFont(font) ; cp5.addButton("Beep1") .setPosition(100, 350) .setSize(120, 70) .setFont(font) ; cp5.addButton("Beep2") .setPosition(250, 350) .setSize(120, 70) .setFont(font) ; cp5.addButton("song") .setPosition(400, 350) .setSize(120, 70) .setFont(font) ; cp5.addButton("Buzzon") .setPosition(175, 450) .setSize(120, 70) .setFont(font) ; cp5.addButton("Buzzoff") .setPosition(325, 450) .setSize(120, 70) .setFont(font) ; } void draw(){ background(255, 255 , 255); fill(255, 0, 0); textFont(font); text("Assignment 3 - GUI", 210, 40); text("LED", 285, 80); text("Buzzer",270,315); } void red(){ port.write('r'); } void green(){ port.write('g'); } void blue(){ port.write('b'); } void alloff(){ port.write('f'); } void allon(){ port.write('o'); } void Beep1(){ port.write('1'); } void Beep2(){ port.write('2'); } void song(){ port.write('6'); } void Buzzon(){ port.write('4'); } void Buzzoff(){ port.write('5'); }